package com.njthird.busi.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.njthird.common.annotation.Log;
import com.njthird.common.core.controller.BaseController;
import com.njthird.common.core.domain.AjaxResult;
import com.njthird.common.enums.BusinessType;
import com.njthird.busi.domain.BusiCuscapitalflow;
import com.njthird.busi.service.IBusiCuscapitalflowService;
import com.njthird.common.utils.poi.ExcelUtil;
import com.njthird.common.core.page.TableDataInfo;

/**
 * 客户资金流水Controller
 * 
 * @author njthird
 * @date 2020-08-10
 */
@RestController
@RequestMapping("/busi/cuscapitalflow")
public class BusiCuscapitalflowController extends BaseController
{
    @Autowired
    private IBusiCuscapitalflowService busiCuscapitalflowService;

    /**
     * 查询客户资金流水列表
     */
    @PreAuthorize("@ss.hasPermi('busi:cuscapitalflow:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusiCuscapitalflow busiCuscapitalflow)
    {
        startPage();
        List<BusiCuscapitalflow> list = busiCuscapitalflowService.selectBusiCuscapitalflowList(busiCuscapitalflow);
        return getDataTable(list);
    }

    /**
     * 导出客户资金流水列表
     */
    @PreAuthorize("@ss.hasPermi('busi:cuscapitalflow:export')")
    @Log(title = "客户资金流水", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusiCuscapitalflow busiCuscapitalflow)
    {
        List<BusiCuscapitalflow> list = busiCuscapitalflowService.selectBusiCuscapitalflowList(busiCuscapitalflow);
        ExcelUtil<BusiCuscapitalflow> util = new ExcelUtil<BusiCuscapitalflow>(BusiCuscapitalflow.class);
        return util.exportExcel(list, "cuscapitalflow");
    }

    /**
     * 获取客户资金流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('busi:cuscapitalflow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(busiCuscapitalflowService.selectBusiCuscapitalflowById(id));
    }

    /**
     * 新增客户资金流水
     */
    @PreAuthorize("@ss.hasPermi('busi:cuscapitalflow:add')")
    @Log(title = "客户资金流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusiCuscapitalflow busiCuscapitalflow)
    {
        return toAjax(busiCuscapitalflowService.insertBusiCuscapitalflow(busiCuscapitalflow));
    }

    /**
     * 修改客户资金流水
     */
    @PreAuthorize("@ss.hasPermi('busi:cuscapitalflow:edit')")
    @Log(title = "客户资金流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusiCuscapitalflow busiCuscapitalflow)
    {
        return toAjax(busiCuscapitalflowService.updateBusiCuscapitalflow(busiCuscapitalflow));
    }

    /**
     * 删除客户资金流水
     */
    @PreAuthorize("@ss.hasPermi('busi:cuscapitalflow:remove')")
    @Log(title = "客户资金流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busiCuscapitalflowService.deleteBusiCuscapitalflowByIds(ids));
    }
}
